package com.woniuxy.controller;

import com.woniuxy.entity.Waybill;
import com.woniuxy.entity.dto.SaveDTO;
import com.woniuxy.entity.dto.WaybillDTO;
import com.woniuxy.service.WaybillService;
import com.woniuxy.util.PageData;
import com.woniuxy.util.ResponseData;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/waybill")
public class WaybillController {

    @Resource
    private WaybillService waybillService;


    @PostMapping("/queryWaybill")
    public ResponseData<?> queryWaybill(@RequestBody PageData<WaybillDTO> pageData){
        return  waybillService.queryWaybill(pageData);
    }

    @GetMapping("/queryTransport")
    public ResponseData<?> queryTransport(){
        return  waybillService.queryTransport();
    }

    @GetMapping( "/queryBasicDetail/{id}")
    public ResponseData<?> queryBasicDetail(@PathVariable("id") String id) {
        return waybillService.queryBasicDetail(id);
    }

    @GetMapping( "/querySendDetail/{id}")
    public ResponseData<?> querySendDetail(@PathVariable("id") String id) {
        return waybillService.querySendDetail(id);
    }
    @GetMapping( "/queryGoodsDetail/{id}")
    public ResponseData<?> queryGoodsDetail(@PathVariable("id") String id) {
        return waybillService.queryGoodsDetail(id);
    }

    @GetMapping( "/queryAllLogisticsPartner")
    public ResponseData<?> queryAllLogisticsPartner() {
        return waybillService.queryAllLogisticsPartner();
    }

    @GetMapping( "/queryDriver")
    public ResponseData<?> queryDriver() {
        return waybillService.queryDriver();
    }

    @GetMapping( "/queryBySelect/{id}")
    public ResponseData<?> queryBySelect(@PathVariable("id") String id) {
        return waybillService.queryById(id);
    }

    @GetMapping( "/querySelectDriver/{id}")
    public ResponseData<?> querySelectDriver(@PathVariable("id") String id) {
        return waybillService.queryDriverById(id);
    }

    @GetMapping( "/queryLicenseLate/{id}")
    public ResponseData<?> queryLicenseLate(@PathVariable("id") String id) {
        return waybillService.queryCar(id);
    }

    @GetMapping( "/querySelectCar/{id}")
    public ResponseData<?> querySelectCar(@PathVariable("id") String id) {
        return waybillService.queryCarById(id);
    }

    @GetMapping( "/queryDispatch/{id}")  //承运商回显
    public ResponseData<?> queryDispatch(@PathVariable("id") String id) {
        return waybillService.queryDispatch(id);
    }
    @GetMapping( "/queryD/{id}")  //司机回显
    public ResponseData<?> queryD(@PathVariable("id") String id) {
        return waybillService.queryD(id);
    }

    @GetMapping( "/queryC/{id}")  //司机回显
    public ResponseData<?> queryC(@PathVariable("id") String id) {
        return waybillService.queryC(id);
    }

    @GetMapping( "/queryDate/{id}")  //司机回显
    public ResponseData<?> queryDate(@PathVariable("id") String id) {
        return waybillService.queryDate(id);
    }
    @PostMapping( "/save")  //保存修改
    public ResponseData<?> save(@RequestBody WaybillDTO waybillDTO) {
        return waybillService.save(waybillDTO);
    }

    @GetMapping( "/Cancel/{id}")  //取消调度
    public ResponseData<?> Cancel(@PathVariable("id") String id) {
        return waybillService.Cancel(id);
    }

    @GetMapping( "/judgment/{id}")  //判断能否点击分配承运商按钮
    public ResponseData<?> judgment(@PathVariable("id") String id) {
        return waybillService.judgment(id);
    }

    @PostMapping("/batchDel")
    public ResponseData<?> batchDel(@RequestBody List<String> ids){
        return waybillService.batchDel(ids);
    }

    @GetMapping("/export")
    public ResponseData<?> exportYiData(HttpServletResponse response){
        return waybillService.exportYiData(response);
    }

}
